package com.paypalpay.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author: songgt
 * @date: 2018-09-08 10:46
 */
@Configuration
@EnableSwagger2
public class SwaggerConfig {
    /**
     * 读取application.yml配置文件中对swagger的配置
     */
    @Value("${swagger2.host}")
    private String host;
    @Bean
    public Docket createLogin(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("H5接入方式接口[V1.0]")
                .host(host)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.paypalpay.controller.interfaces"))
                .build();
    }
    @Bean
    public Docket createLogin1(){
        return new Docket(DocumentationType.SWAGGER_2).groupName("接口接入方式接口[V1.0]")
                .host(host)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.paypalpay.controller.appinterface"))
                .build();
    }
    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("领科H5商城")
                .description("")
                .version("1.0")
                .termsOfServiceUrl("http://wx.linksfield.net")
                .contact(new Contact("","",""))
                .build();
    }

}
